<?php
/**
 * Created by PhpStorm.
 * User: lenovo
 * Date: 2019/1/9
 * Time: 20:59
 */
//连接swoole tcp 服务
$client=new swoole_client(SWOOLE_SOCK_TCP);

if(!$client->connect('192.168.1.110',9501)){
    echo '连接失败';
    exit(1);
}

//接收消息
fwrite(STDOUT,'请输入消息:');
$msg=trim(fgets(STDIN));

//发送消息给tcp server
if(!$client->send($msg)){
    echo '信息发送失败，请重试！';
    exit(1);
}

//接收来自server 的数据
$result=$client->recv();
print_r($result);
echo PHP_EOL;